//
//  UIView+Toast.h
//  KangarooDoctor
//
//  Created by mengze on 2024/11/27.
//

#import <UIKit/UIKit.h>
#import "UITextField+Placeholder.h"


@implementation UITextField (Placeholder)

- ( void ) setPlaceholder1:(NSString *) text {
    NSAttributedString *attributedPlaceholder = [[NSAttributedString alloc] initWithString: text attributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1]}];
    self.attributedPlaceholder = attributedPlaceholder;
    
    self.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, 12)];;
    self.leftViewMode = UITextFieldViewModeAlways;
    self.clearButtonMode = UITextFieldViewModeWhileEditing;


    // 创建一个颜色
    UIColor *color = [UIColor redColor];
    // 创建一个视图，并设置背景颜色
    UIImageView * view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [view setImage:[UIImage imageNamed:@"ui_icon_clear"]];
    view.backgroundColor = color;
     

     
    // 设置clearButton的背景图片
    UIButton *clearButton = [self valueForKey:@"_clearButton"];
    [clearButton setBackgroundImage:[UIImage imageNamed:@"ui_icon_clear"] forState:UIControlStateNormal];
    
    [self setBackgroundColor:[UIColor colorWithRed:(CGFloat)247/255.0 green:(CGFloat)248/255.0 blue:(CGFloat)254/255.0 alpha:(CGFloat)1.0]];
}

@end

